package com.zl.zlbaseproject.presenter.home;

import android.content.Context;

import com.zl.zlbaseproject.base.presenter.BasePresenter;
import com.zl.zlbaseproject.model.net.api.ApiService;
import com.zl.zlbaseproject.model.net.bean.BaseNetBean;
import com.zl.zlbaseproject.model.net.bean.TestBean;
import com.zl.zlbaseproject.model.net.engine.RetrofitHelper;
import com.zl.zlbaseproject.model.net.engine.TransformHelper;
import com.zl.zlbaseproject.model.net.engine.intercepter.HttpResult;

/**
 * Created by 郑磊 on 2018/6/13.
 */

public class HomeFragmentPresenter extends BasePresenter<HomeFragmentComtract.View> implements HomeFragmentComtract.Presenter{


    public HomeFragmentPresenter(HomeFragmentComtract.View view, Context context) {
        super(view, context);
    }

    @Override
    public void LoadHomeData() {

        RetrofitHelper
                .creatApi(ApiService.class)
                .getRestaurantDetail()
                .compose(TransformHelper.transformOnMain(TestBean.class))
                .subscribe(new HttpResult<BaseNetBean<TestBean>>(mContext) {
                    @Override
                    protected void onFailed() {
//                        MyToast.show(mContext,"========error=====");
//                       mView.setLayoutFailed();
                        mView.onLoadFailed();
                    }

                    @Override
                    protected void onSuccess(BaseNetBean<TestBean> testBeanBaseNetBean) {
//                        TestBean body = testBeanBaseNetBean.body;
//                        mView.setLayoutSuccess();
                        mView.onLoadFailed();
//                        MyToast.show(MainActivity.this,"========success=====");
                    }
                });
    }
}
